package sc.tool.sqlgen.branchinfo;

public class ResultHolder {

    private static ThreadLocal<CompareResult> compareResultLocal = new ThreadLocal<CompareResult>();
    private static ThreadLocal<ParseResult> parseResultLocal = new ThreadLocal<ParseResult>();

    /**
     * 默认构造函数
     */
    public ResultHolder() {
    }

    public static CompareResult getCompareResult() {
        if (compareResultLocal.get() == null) {
            compareResultLocal.set(new CompareResult());
        }

        return compareResultLocal.get();
    }

    public static ParseResult getParseResult() {
        if (parseResultLocal.get() == null) {
            parseResultLocal.set(new ParseResult());
        }

        return parseResultLocal.get();
    }

    public static void setParseResult(ParseResult parseResult) {
        parseResultLocal.set(parseResult);
    }

    public static void setCompareResult(CompareResult compareResult) {
        compareResultLocal.set(compareResult);
    }

    public static void clear() {
        parseResultLocal.remove();
        compareResultLocal.remove();
    }
}
